package com.sys.core.utils;

import org.dom4j.Document;
import org.dom4j.Element;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created by 汤伟杰 on 2017/7/20.
 */
public class Dom4jUtils {
    public static Map<String, String> Dom2Map(Document doc){
        Map<String, String> map = new HashMap<String, String>();
        if(doc == null)
            return map;
        Element root = doc.getRootElement();
        for (Iterator iterator = root.elementIterator(); iterator.hasNext();) {
            Element e = (Element) iterator.next();
            map.put(e.getName(), e.getText());
        }
        return map;
    }
}
